#ifndef TEXTUREMANAGER_H
#define TEXTUREMANAGER_H

#include <QObject>
#include <SFML/Graphics.hpp>
#include <QPair>
#include <QList>
#include <Shinygami/spriteanimate.hpp>
#include <Shinygami/texturelist.hpp>

class TextureManager : public QObject, public Shiny::TextureList
{
    Q_OBJECT
public:
    friend class AnimationManager;

    struct TexturePair
    {
        QString     first;
        sf::Texture second;
        QString     source;
    };

    explicit TextureManager(QObject *parent = 0);

    TexturePair*              GetPairByName(const QString& name);
    const sf::Texture*        GetByName(const QString& name) const;
    sf::Texture*              GetByName(const QString &name);
    const QList<TexturePair>& GetList(void)                    { return (_textures); }
    void                      SetDirectory(const QString& dir) { _directory = dir; }

    void                      Load(const QString& filepath);
    void                      Save(const QString& filepath);
    void                      Clear(void) { _textures.clear(); }

    void                      TriggerTextureAdded(QString s) { TextureAdded(s); }

signals:
    void                      TextureAdded(QString);
    void                      TextureDeleted(QString);

public slots:
    bool                      AddFile(QString);
    void                      DeleteTexture(QString);

private:
    QList<TexturePair>        _textures;
    QString                   _directory;
};

#endif // TEXTUREMANAGER_H
